package com.example.administrator.myapplication;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.example.administrator.myapplication.util.DB;

public class MainActivity extends AppCompatActivity {

    private EditText studentIdEd;
    private EditText usernameEd;
    private Button loginBtn;
    private TextView forgetStudentIdTv;
    private TextView signInTv;
    private String usernameStr;
    private String studentStr;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();

        initEvent();
    }
    private void initView(){
        studentIdEd = findViewById(R.id.student_id_et);
        usernameEd = findViewById(R.id.username_et);
        loginBtn = findViewById(R.id.login_btn);
        forgetStudentIdTv = findViewById(R.id.forget_student_id_tv);
        signInTv = findViewById(R.id.sign_in_tv);


    }private void initData(){
        usernameStr = usernameEd.getText().toString()+"";
        studentStr = studentIdEd.getText().toString()+"";

    }private  void initEvent(){
        loginBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                initData();
                DB db =new DB(MainActivity.this);
                db.loginSelect(usernameStr,studentStr);


            }
        }); signInTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent =new Intent(MainActivity.this,SignInActivity.class);
                startActivity(intent);
            }
        }); forgetStudentIdTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });

    }
}
